import {request} from '@/base/Request';
import {Software} from '@/base/model/Software'
import qs from 'qs'

export function postSoftware(params: {
  describe: string,
  extName: string,
  firmwareVersions: number,
  modelId: number,
  sortId: number,
  url: string,
  versions: number,
  issueStatus: string,
  productType: number
}) {
  return request.post(Software, '/api/software', qs.stringify(params))
}

export function getSoftware(params: {
  pageIndex: number,
  pageSize: number,
  sortDirection: string,
  accountName: string,
  versions: string,
  issueStatus: string,
  modelId: 0
}) {
  return request.getPage(Software, '/api/software', {params})
}

export function getVersions(params?: { modelId: number }) {
  return request.getArray(String, '/api/software/version', {params})
}

export function getSoftwareId(
  id: number
) {
  return request.get(Software, `/api/software/${id}`)
}

export function PutSoftwareId(params: {
  describe: string,
  extName: string,
  firmwareVersions: number,
  id: number,
  issueStatus: string,
  modelId: number,
  sortId: number,
  url: string,
  productType: number
}) {
  return request.put(Software, `/api/software/${params.id}`, qs.stringify(params))
}

export function deleteSoftwareId(
  id: number
) {
  return request.delete(`/api/software/${id}`)
}
